package com.tan.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
@Repository
public class AccountDaoImpl implements IAccountDao {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void addMoney(String account, double money) {
        String sql = "update t_account set money=money+? where name=?";
        jdbcTemplate.update(sql, money,account);
    }

    public void subMoney(String account, double money) {
        String sql = "update t_account set money=money-? where name=?";
        jdbcTemplate.update(sql,money,account);
    }

    public JdbcTemplate getJdbcTemplate() {
        return jdbcTemplate;
    }

    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }
}
